package com.googlecode.flealancemarket.metamodel.beans;

import com.googlecode.flealancemarket.core.beans.BaseBean;
import com.googlecode.flealancemarket.metamodel.Category;
import com.googlecode.flealancemarket.metamodel.Employer;
import com.googlecode.flealancemarket.metamodel.Job;
import com.googlecode.flealancemarket.metamodel.JobMessage;

import java.sql.Date;
import java.util.Calendar;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class JobBean extends BaseBean implements Job {

    private Employer author;
    private Date creationTime = new Date(Calendar.getInstance().getTimeInMillis());
    private Date endingTime;
    private Category category;
    private int lowerBudget;
    private int upperBudget;
    private int estimatedTime;
    private String description;
    private List<JobMessage> jobMessages;

    @ManyToOne(targetEntity=EmployerBean.class)
    public Employer getAuthor() {
        return author;
    }

    public void setAuthor(Employer author) {
        this.author = author;
    }

    public Date getCreationTime() {
        return creationTime;
    }

    public void setCreationTime(Date creationTime) {
        this.creationTime = creationTime;
    }

    public Date getEndingTime() {
        return endingTime;
    }

    public void setEndingTime(Date endingTime) {
        this.endingTime = endingTime;
    }

    @ManyToOne(targetEntity=CategoryBean.class, fetch=FetchType.LAZY)
    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public int getLowerBudget() {
        return lowerBudget;
    }

    public void setLowerBudget(int lowerBudget) {
        this.lowerBudget = lowerBudget;
    }

    public int getUpperBudget() {
        return upperBudget;
    }

    public void setUpperBudget(int upperBudget) {
        this.upperBudget = upperBudget;
    }

    public int getEstimatedTime() {
        return estimatedTime;
    }

    public void setEstimatedTime(int estimatedTime) {
        this.estimatedTime = estimatedTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @OneToMany(targetEntity=JobMessageBean.class, mappedBy="job", fetch=FetchType.LAZY)
    public List<JobMessage> getJobMessages() {
        return jobMessages;
    }

    public void setJobMessages(List<JobMessage> jobMessages) {
        this.jobMessages = jobMessages;
    }

}